
import request from '@/utils/request'

// const apiurl = `http://localhost:3000`
const apiurl = `https://webdeploy.bepicgamescn.com`
// const apiurl = `https://cdn.rfcode.top/Users`

export function register(data) {
  return request({
    url: '/Users/register',
    method: 'post',
    data,
    baseURL: apiurl
  })
}

export function login(data) {
  return request({
    url: '/Users/login',
    method: 'post',
    data,
    baseURL: apiurl
  })
}

export function getInfo(token) {
  return request({
    url: '/Users/info',
    method: 'get',
    params: { token },
    baseURL: apiurl
  })
}

export function logout() {
  return request({
    url: '/Users/logout',
    method: 'post',
    baseURL: apiurl
  })
}

export function upAvatar(data) {
  return request({
    url: '/Users/upAvatar',
    method: 'post',
    data,
    baseURL: apiurl
  })
}

export function getUsers(params = {}) {
  return request({
    url: '/Users/users',
    method: 'get',
    params,
    baseURL: apiurl
  })
}

export function updateUser(username, data) {
  return request({
    url: `/Users/users/${username}`,
    method: 'put',
    data,
    baseURL: apiurl
  })
}

export function deleteUser(username) {
  return request({
    url: `/Users/users/${username}`,
    method: 'delete',
    baseURL: apiurl
  })
}
